<?php

namespace App\Http\Controllers;

use GuzzleHttp\Client;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class IndexController extends Controller
{
    public function index(Request $request)
    {

        // dd($request->all());
        return view("index");
    }



    /**
     * 请求后端接口
     *
     * @param Request $request
     * @return void
     * @Description
     * @example
     * @since
     */
    public function req(Request $request)
    {   
        //请求路由
        $r = $request->input("r");

        $ip = "http://159.138.139.36{$r}";

        $header = [
            'Accept-Language' => 'zh'
        ];

        if($request->filled('token')){
            $header['token'] = $request->input("token");
            // $this->token($header['token']);
        }

        $client = new Client();
        $resp = $client->post($ip, [
            'json'    => $request->all(),
            'headers' => $header
        ]);
        return $resp->getBody()->getContents();
    }


    public function log(Request $request){
        Log::info("token",$request->all());
    }
}
